package org.example.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Main2 {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        Collections.addAll(students,
                new Student(1,"xiao1hei",58,true,60.0),
                new Student(2,"xiao2hei",38,true,40.0),
                new Student(3,"zhang3hei",38,false,75.0),
                new Student(4,"xiao4hei",18,false,80.0),
                new Student(5,"zhang5hei",38,true,90.0),
                new Student(6,"xiao6hei",88,true,70.0),
                new Student(7,"xiao7hei",58,false,70.0),
                new Student(8,"xiao8hei",38,true,60.0)
        );
        List<String> collect = students.stream().map(s -> s.getName()).collect(Collectors.toList());
        System.out.println(collect);
        List<Student> zhang = students.stream().peek(s -> {
            if (s.getName().startsWith("zhang"))
                s.setScore(s.getScore() + 5);
        }).collect(Collectors.toList());

        System.out.println(zhang);
    }
}
